package org.example.stream.demo;

import org.example.stream.demo.entity.User;

import java.util.List;
import java.util.stream.Collectors;

public class LimitMain {
    public static void main(String[] args) {
        List<User> list = UserBuilder.bindings();

        List<User> collect = list.stream().sorted((l1, l2) -> l2.getAge() - l1.getAge())
                .limit(2)
                .collect(Collectors.toList());

        System.out.println(collect);
    }
}
